﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
    <meta id="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
    <meta name="format-detection" content="telephone=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" type="image/x-icon" href="./favicon.png" />
    <link rel="stylesheet" type="text/css" href="./js/vxe-table/vxe-pc-ui@3.3.85/style.min.css" />
    <link rel="stylesheet" type="text/css" href="./js/vxe-table/vxe-table@3.12.10/style.min.css" />
    <title>远控服务管理</title>

    <style type="text/css">
        html,
        body {
            margin: 0 auto;
            font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", "微软雅黑", sans-serif;
            width: 100%;
            height: 100%;
        }

        #app {
            padding: 15px 10% 15px 10%;
            min-width: 600px;
            position: relative;
        }

        .tip {
            border-left: 4px solid #409eff;
            padding: 12px 24px 12px 30px;
            margin: 2em 0;
            background-color: #f8f8f8;
        }

        .divForm {
            margin-bottom: 24px;
            border: 1px solid #ebebeb;
            border-radius: 3px;
            transition: .2s;
            padding: 24px;
        }
    </style>
</head>
<body>
    <script type="text/javascript" src="./js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="./js/vue-2.6.10.min.js"></script>
    <script type="text/javascript" src="./js/crypto-js.min.js"></script>


    <script type="text/javascript" src="./js/vxe-table/xe-utils@3.7.0/xe-utils.umd.min.js"></script>
    <script type="text/javascript" src="./js/vxe-table/vxe-pc-ui@3.3.85/index.umd.min.js"></script>
    <script type="text/javascript" src="./js/vxe-table/vxe-table@3.12.10/index.umd.min.js"></script>

    <script type="text/javascript" src="./js/Common.js"></script>
    <script type="text/javascript" src="./js/TimeHelper.js"></script>
    <script type="text/javascript" src="./js/MinCache.js"></script>

    <div id="app">
        <!--tab切换组件,因为面板内绑定数据有问题，将面板内的内容提出到外面，通过切换事件改变显示内容-->
        <vxe-tabs padding v-model="activeTab" @tab-change="tabChange">
            <vxe-tab-pane title="服务信息" name="tab1" key="tab1"></vxe-tab-pane>
            <vxe-tab-pane title="会话列表" name="tab2" key="tab2"></vxe-tab-pane>
            <vxe-tab-pane title="角色列表" name="tab3" key="tab3"></vxe-tab-pane>
            <vxe-tab-pane title="操作员列表" name="tab4" key="tab4"></vxe-tab-pane>
            <vxe-tab-pane title="操作员操作列表" name="tab5" key="tab5"></vxe-tab-pane>
        </vxe-tabs>

        <!--服务信息面板-->
        <div v-show="activeTab==='tab1'">
            <div class="tip">
                登录
            </div>
            <div class="divForm">
                <vxe-form>
                    <vxe-form-item align="left" span="24">
                        <template #default>
                            <!--是否必须在服务器使用127.0.0.1域名访问网站-->
                            是否必须使用127.0.0.1域名在服务器访问网站
                            <vxe-switch v-model="IsMastLocal" open-label="是" close-label="否" @change="IsMastLocalChange"></vxe-switch>
                            <div style="color:#ff0000">注:此选项只能在127.0.0.1域名下访问修改</div>
                        </template>
                    </vxe-form-item>
                </vxe-form>
            </div>
            <div class="divForm">
                <vxe-form>
                    <vxe-form-item align="left" span="24">
                        <template #default>
                            <vxe-button @click="ShowChangePasswordForm=true" status="primary">修改登录密码</vxe-button>
                        </template>
                    </vxe-form-item>
                </vxe-form>
            </div>

            <div class="tip">
                服务密钥
            </div>
            <div class="divForm">
                <vxe-form>
                    <vxe-form-item title="服务密钥" span="24">
                        <template #default>
                            <vxe-textarea readonly v-model="ClientKey.PublicKey" placeholder="密钥" :autosize="{ minRows: 4, maxRows: 6 }"></vxe-textarea>
                        </template>
                    </vxe-form-item>

                    <vxe-form-item align="center" span="24">
                        <template #default>
                            <vxe-button @click="UpdateKey" href="javascript:" status="primary">重置密钥</vxe-button>
                            <vxe-button @click="copyToClipboard(ClientKey.PublicKey)" href="javascript:" status="warning">复制到粘贴板</vxe-button>

                        </template>
                    </vxe-form-item>

                </vxe-form>
            </div>
        </div>

        <!--登录弹窗-->
        <vxe-modal v-model="ShowLoginPasswordForm"
                   show-footer
                   :show-close="false"
                   :draggable="false"
                   show-confirm-button
                   lock-view
                   title="登录"
                   :width="600"
                   :confirm-closable="false"
                   @confirm="Login()">
            <vxe-form>
                <vxe-form-item title="登录密码" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="LoginPassword" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>

            </vxe-form>
        </vxe-modal>

        <!--修改密码-->
        <vxe-modal v-model="ShowChangePasswordForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="修改密码"
                   :width="600"
                   esc-closable
                   @confirm="ChangePassword"
                   @cancel="ShowChangePasswordForm=false">
            <vxe-form>
                <vxe-form-item title="原密码" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="LoginPassword" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="新密码" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="NewLoginPassword" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>

            </vxe-form>
        </vxe-modal>

        <!--会话信息面板-->
        <div v-show="activeTab==='tab2'">
            <!--<div class="tip">
                会话列表
            </div>-->
            <div class="divForm">
                <vxe-button v-show="SelectTreeNode==null||SelectTreeNode.SessionType===1" @click="DirAdd" status="success">新增文件夹</vxe-button>
                <vxe-button @click="SessionAdd" status="success">新增会话</vxe-button>
            </div>
            <div class="divForm">
                <div>
                    <vxe-tree ref="treeRef"
                              :node-config="{ isHover: true, isCurrent: true }"
                              children-field="ChildSessionList"
                              key-field="ID"
                              :data="SessionList"
                              @node-click="nodeClick">
                        <template #title="{ node }">
                            <div v-if="node.SessionType==1">
                                <img src="./image/dir.png" style="height :1rem; width :1rem;" />
                                <span>{{ node.Name }}</span>
                            </div>
                            <div v-if="node.SessionType==2" style="cursor: pointer;" @click="sessionNodeClick"> 
                                <img src="./image/computer.png" style="height :1rem; width :1rem; cursor :pointer;" />
                                <span>{{ node.Name }}</span>
                            </div>
                        </template>
                        <template #extra="{ node }">
                            <div v-if="node.ID!='0'">
                                <vxe-button v-if="node.SessionType==1" mode="text" status="primary" icon="vxe-icon-search" @click="DirUpdate(node)">编辑</vxe-button>
                                <vxe-button v-if="node.SessionType==2" mode="text" status="primary" icon="vxe-icon-search" @click="SessionUpdate(node)">编辑</vxe-button>
                                <vxe-button mode="text" status="error" icon="vxe-icon-delete-fill" @click="SessionDelete(node)">删除</vxe-button>
                            </div>
                        </template>
                    </vxe-tree>
                    <vxe-modal v-model="ShowSessionCard" title="会话信息" :height="200" :width="400" :mask="false" :mask-closable="true">
                        <template #default>
                            <div v-if="SelectTreeNode.Data!=null" style="margin-bottom :10px;">{{'服务地址:'+SelectTreeNode.Data.Server}}</div>
                            <div v-if="SelectTreeNode.Data!=null" style="margin-bottom :10px;">{{'说明:'+SelectTreeNode.Data.Description}}</div>
                        </template>
                    </vxe-modal>
                </div>
            </div>

        </div>




        <!--添加/编辑文件夹弹窗-->
        <vxe-modal v-model="ShowDirForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="文件夹信息"
                   :width="600"
                   esc-closable
                   @confirm="DirSave"
                   @cancel="ShowDirForm=false">
            <vxe-form>
                <vxe-form-item title="文件夹名" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.name"></vxe-input>
                    </template>
                </vxe-form-item>

            </vxe-form>
        </vxe-modal>

        <!--添加/编辑会话弹窗-->
        <vxe-modal v-model="ShowSessionForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="会话信息"
                   :width="600"
                   :height="500"
                   esc-closable
                   @confirm="SessionSave"
                   @cancel="ShowSessionForm=false">
            <vxe-form title-colon
                      vertical>
                <vxe-form-item title="会话名" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.name"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="服务器地址" field="name" span="12" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.server"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="端口号" field="name" span="12" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.port"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="用户名" field="name" span="12" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.userName"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="密码" field="name" span="12" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="SessionInfo.password" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="共享磁盘" field="name" span="12" :item-render="{}">
                    <template #default="params">
                        <vxe-radio-group v-model="SessionInfo.isShareDisk">
                            <vxe-radio-button label="Y" content="是"></vxe-radio-button>
                            <vxe-radio-button label="N" content="否"></vxe-radio-button>
                        </vxe-radio-group>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="备注" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-textarea v-model="SessionInfo.description" placeholder="" :autosize="{ minRows: 3, maxRows: 6 }"></vxe-textarea>
                    </template>
                </vxe-form-item>

            </vxe-form>
        </vxe-modal>

        <!--角色信息-->
        <div v-show="activeTab==='tab3'">
            <div class="divForm">
                <vxe-button @click="RoleAdd" status="success">新增角色</vxe-button>
            </div>

            <vxe-table round
                       border
                       stripe
                       show-overflow
                       ref="xTable1"
                       :data="RoleList"
                       :loading="RoleLoading">
                <vxe-column type="seq" width="70"></vxe-column>
                <vxe-column field="RoleName" title="角色名称"></vxe-column>
                <vxe-column title="操作" fixed="right" width="260">
                    <template #default="row">
                        <vxe-button @click="RoleUpdate(row.row)" status="warning">修改</vxe-button>
                        <vxe-button @click="RoleDelete(row.row)" status="error">删除</vxe-button>
                        <vxe-button @click="RoleSession(row.row)" status="primary">关联会话</vxe-button>
                    </template>
                </vxe-column>
            </vxe-table>
        </div>

        <!--添加/编辑角色信息弹窗-->
        <vxe-modal v-model="ShowRoleForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="角色信息"
                   :width="600"
                   esc-closable
                   @confirm="RoleSave"
                   @cancel="ShowRoleForm=false">
            <vxe-form>
                <vxe-form-item title="角色名称" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="RoleInfo.name"></vxe-input>
                    </template>
                </vxe-form-item>

            </vxe-form>
        </vxe-modal>

        <!--角色关联会话弹窗-->
        <vxe-modal v-model="ShowRoleSessionForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="关联会话"
                   :width="600"
                   :height="500"
                   esc-closable
                   @confirm="RoleSessionAdd"
                   @cancel="ShowRoleSessionForm=false">
            <vxe-table border
                       empty-text="没有更多数据了！"
                       ref="treeRoleSessionRef"
                       :tree-config="{rowField: 'ID', childrenField: 'ChildSessionList'}"
                       :row-config="{keyField:'ID'}"
                       :checkbox-config="{reserve: true, highlight: true}"
                       :data="SessionList">
                <!--<vxe-column field="ID" title="ID" ></vxe-column>-->
                <vxe-column type="checkbox" width="40">

                </vxe-column>
                <vxe-column field="Name" title="会话名称" tree-node>
                    <template #default="{ row }">
                        <span>
                            <template v-if="row.SessionType===1">
                                <img src="./image/dir.png" style="height :1rem; width :1rem;" />

                            </template>
                            <template v-if="row.SessionType==2">
                                <img src="./image/computer.png" style="height :1rem; width :1rem;" />
                            </template>
                            <span>{{ row.Name }}</span>
                        </span>
                    </template>
                </vxe-column>
            </vxe-table>

        </vxe-modal>

        <!--操作员信息-->
        <div v-show="activeTab==='tab4'">
            <div class="divForm">
                <vxe-button @click="UserAdd" status="success">新增操作员</vxe-button>
            </div>

            <vxe-table round
                       border
                       stripe
                       show-overflow
                       ref="xTable2"
                       :data="UserList"
                       :loading="UserLoading">
                <vxe-column type="seq" width="50"></vxe-column>
                <vxe-column field="UserID" title="登录名" width="90"></vxe-column>
                <vxe-column field="UserName" title="操作员名称" width="90"></vxe-column>
                <vxe-column field="IsAdmin " title="超级操作员" width="90">
                    <template #default="{ row }">
                        <vxe-tag v-if="row.IsAdmin=='Y'" status="primary" content="是"></vxe-tag>
                        <vxe-tag v-if="row.IsAdmin=='N'" status="warning" content="否"></vxe-tag>
                    </template>
                </vxe-column>
                <vxe-column field="Remark " title="备注"></vxe-column>
                <vxe-column title="操作" fixed="right" width="380">
                    <template #default="row">
                        <vxe-button @click="UserUpdate(row.row)" status="warning">修改</vxe-button>
                        <vxe-button @click="UserDelete(row.row)" status="error">删除</vxe-button>
                        <vxe-button @click="UserChangePassword(row.row)" status="info">修改密码</vxe-button>
                        <vxe-button @click="UserRole(row.row)" status="primary">关联角色</vxe-button>
                    </template>
                </vxe-column>
            </vxe-table>
        </div>

        <!--添加/编辑操作员信息弹窗-->
        <vxe-modal v-model="ShowUserForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="操作员信息"
                   :width="600"
                   esc-closable
                   @confirm="UserSave"
                   @cancel="ShowUserForm=false">
            <vxe-form title-colon
                      title-align="right"
                      title-width="120">
                <vxe-form-item title="登录名" field="userid" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="UserInfo.userid"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="操作员名称" field="name" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="UserInfo.name"></vxe-input>
                    </template>
                </vxe-form-item>
                <vxe-form-item title="超级管理员" field="isAdmin" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-radio-group v-model="UserInfo.isAdmin">
                            <vxe-radio-button label="Y" content="是"></vxe-radio-button>
                            <vxe-radio-button label="N" content="否"></vxe-radio-button>
                        </vxe-radio-group>
                    </template>
                </vxe-form-item>
                <vxe-form-item v-if="UserInfo.id===''" title="密码" field="password" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="UserInfo.password" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>
            </vxe-form>
        </vxe-modal>

        <!--修改操作员密码弹窗-->
        <vxe-modal v-model="ShowUserChangePasswordForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="操作员密码"
                   :width="600"
                   esc-closable
                   @confirm="UserPasswordSave"
                   @cancel="ShowUserChangePasswordForm=false">
            <vxe-form title-colon
                      title-align="right"
                      title-width="100">
                <vxe-form-item title="密码" field="password" span="24" :item-render="{}">
                    <template #default="params">
                        <vxe-input v-model="UserInfo.password" type="password" clearable></vxe-input>
                    </template>
                </vxe-form-item>
            </vxe-form>
        </vxe-modal>

        <!--操作员关联角色弹窗-->
        <vxe-modal v-model="ShowUserRoleForm"
                   show-footer
                   show-confirm-button
                   show-cancel-button
                   title="关联角色"
                   :width="600"
                   :height="500"
                   esc-closable
                   @confirm="UserRoleAdd"
                   @cancel="ShowUserRoleForm=false">
            <vxe-table border
                       empty-text="没有更多数据了！"
                       ref="treeUserRoleRef"
                       :column-config="{resizable: true}"
                       :row-config="{keyField:'ID'}"
                       :checkbox-config="{highlight: true}"
                       :data="RoleList">
                <vxe-column type="checkbox" width="40"></vxe-column>
                <vxe-column field="Name" title="角色名称" tree-node>
                    <template #default="{ row }">
                        <span>
                            <span>{{ row.RoleName }}</span>
                        </span>
                    </template>
                </vxe-column>
            </vxe-table>

        </vxe-modal>

        <!--操作员操作信息-->
        <div v-show="activeTab==='tab5'">
            <div class="divForm">
                开始时间<vxe-date-picker v-model="UserLogBeginTime" type="datetime" :default-value="new Date()"></vxe-date-picker>
                结束时间<vxe-date-picker v-model="UserLogEndTime" type="datetime" :default-value="new Date()"></vxe-date-picker>
                <vxe-button @click="UserLogLoad" status="primary">查询</vxe-button>
            </div>

            <vxe-table round
                       border
                       stripe
                       show-overflow
                       ref="xTable3"
                       :data="UserLogList">
                <vxe-column type="seq" width="50"></vxe-column>
                <vxe-column field="CreateTime" title="操作时间" width="200"></vxe-column>
                <vxe-column field="LogKey" title="操作类型" width="160"></vxe-column>
                <vxe-column field="LogValue" title="操作信息"></vxe-column>
            </vxe-table>
        </div>


    </div>



    <script>
        $(function () {
            jQuery.support.cors = true;

            var Service = "";

            var that;

            var vm = new Vue({
                el: '#app',
                data: function () {
                    return {
                        TokenID: '',
                        ShowLoginPasswordForm: false,//是否显示登录窗口
                        IsMastLocal: true,//是否必须在服务器使用127.0.0.1域名访问网站
                        LoginPassword: '',//登录密码
                        NewLoginPassword: '',//新密码
                        ClientKey: {
                            PublicKey: "",//解密私钥
                        },
                        activeTab: 'tab1',//当前激活的TAB
                        SessionList: [],//会话列表
                        SessionInfo: {
                            id: '',
                            name: '',
                            server: '',
                            port: 3389,
                            userName: '',
                            password: '',
                            isShareDisk: 'N',
                            description: '',
                        },
                        SelectTreeNode: null,//选中的会话列表节点
                        ShowSessionCard: false,//是否显示会话信息框
                        SessionCardLeft: 0,//会话信息框左坐标
                        SessionCardTop: 0,//会话信息框上坐标
                        ShowDirForm: false,//是否显示文件夹编辑窗口
                        ShowSessionForm: false,//是否显示会话编辑窗口
                        ShowChangePasswordForm: false,//是否显示修改密码窗口
                        RoleLoading: false,//是否在加载角色数据
                        RoleList: [],//角色列表
                        ShowRoleForm: false,//是否显示角色编辑窗口
                        RoleInfo: {
                            id: '',
                            name: '',
                        },
                        ShowRoleSessionForm: false,//是否显示角色关联会话窗口
                        UserList: [],//用户列表
                        UserLoading: false,//是否在加载用户数据
                        ShowUserForm: false,//是否显示用户编辑窗口
                        UserInfo: {
                            id: '',
                            userid: '',
                            name: '',
                            isAdmin: 'N',
                            password: '',
                        },
                        ShowUserChangePasswordForm: false,//是否显示用户修改密码窗口
                        ShowUserRoleForm: false,//是否显示用户关联会话窗口
                        UserLogBeginTime: '',//操作员日志开始时间
                        UserLogEndTime: '',//操作员日志结束时间
                        UserLogList: [],//操作员操作日志
                    }
                },
                watch: {
                    SessionList(newVal, oldVal) {

                    }
                },
                components: {},
                created: function () {
                    that = this;
                    this.Init();
                },
                mounted: function () {
                    window.vm = this;
                },
                computed: {

                },
                methods: {
                    Init() {
                        //初始化数据
                        that.TokenID = cache.get('_TokenID');
                        if (IsEmpty(that.TokenID)) {
                            _param = {

                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/TokenIDGet",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: false, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -1) {

                                    }
                                    if (data.Success === 1) {
                                        that.TokenID = data.Result.TokenID;
                                        cache.set('_TokenID', that.TokenID);
                                    }
                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }
                        _param = {

                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/NeedLoginPassword",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {

                                }
                                if (data.Success === 1) {
                                    that.IsMastLocal = data.Result.IsMastLocal;
                                    if (data.Result.NeedLoginPassword === 1) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    else {
                                        that.tabChange();
                                    }
                                }
                                if (data.Success === 2) {
                                    //已经登录
                                    that.tabChange();
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });


                        let _day = new Date();
                        _day.setDate(_day.getDate() - 1);
                        _day.setHours(0, 0, 0, 0);
                        this.UserLogBeginTime = _day;

                        _day = new Date();
                        _day.setDate(_day.getDate());
                        _day.setHours(23, 59, 59, 0);
                        this.UserLogEndTime = _day;

                    },
                    IsMastLocalChange(e) {
                        //修改是否必须使用127.0.0.1域名在服务器访问网站
                        _param = {
                            IsMastLocal: that.IsMastLocal,
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/ChangeIsMastLocal",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {

                                }
                                if (data.Success === 1) {
                                    that.IsMastLocal = data.Result.IsMastLocal;
                                    VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    Login() {
                        //登录
                        that.TokenID = cache.get('_TokenID');
                        if (IsEmpty(that.TokenID)) {
                            _param = {

                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/TokenIDGet",
                                data: {
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: false, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -1) {

                                    }
                                    if (data.Success === 1) {
                                        that.TokenID = data.Result.TokenID;
                                        cache.set('_TokenID', that.TokenID);
                                    }
                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });
                        }


                        _param = {
                            LoginPassword: that.LoginPassword,
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/Login",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {

                                }
                                if (data.Success === 1) {
                                    that.ShowLoginPasswordForm = false;
                                    that.PublicKeyLoad();
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    SessionListLoad() {
                        //获取会话列表

                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                        };
                        $.ajax({
                            type: "post",
                            url: Service + "/api/Rdp/SessionListGet",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                console.log('SessionListGet', data);
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.SessionList = data.Result;
                                    that.$nextTick(() => {
                                        that.$refs.treeRef.setAllExpandNode(true);
                                    });
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    PublicKeyLoad() {
                        //获取当前公钥信息
                        that.TokenID = cache.get('_TokenID');
                        let _param = {

                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/ClientKey/PublicKeyGet",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                console.log('PublicKeyGet', data);
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.ClientKey.PublicKey = data.Result.PublicKey;
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    UpdateKey() {
                        //更新密钥
                        VxeUI.modal.confirm({
                            title: '提示',
                            content: '您确定要更新密钥吗？原密钥将失效!',
                            okText: '确定',
                            cancelText: '取消',
                            mask: true,
                            lockView: false,
                            escClosable: true
                        }).then((result) => {
                            if (result === 'confirm') {
                                // 用户点击确定按钮后的操作
                                that.TokenID = cache.get('_TokenID');
                                let _param = {

                                };

                                $.ajax({
                                    type: "post",
                                    url: Service + "/api/ClientKey/ClientKeyCreate",
                                    data: {
                                        TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                        ParamStr: JSON.stringify(_param)
                                    },
                                    async: true, //同步请求
                                    timeout: 10000, //超时时间设置，单位毫秒
                                    dataType: 'json',
                                    crossDomain: true,
                                    success: function (data) {
                                        console.log('ClientKeyCreate', data);
                                        if (data.Success === 0) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === -999) {
                                            that.ShowLoginPasswordForm = true;
                                        }
                                        if (data.Success === -1) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === 1) {
                                            let _options = {
                                                content: '密钥重置成功!',
                                                title: '提示',
                                                status: 'warning'
                                            }
                                            VXETable.modal.alert(_options)
                                            that.ClientKey.PublicKey = data.Result.PublicKey;
                                        }

                                    },
                                    error: function (data) {
                                        console.log('服务器执行失败' + data.responseText);
                                    }
                                });
                            }

                        }).catch(() => {
                            // 用户点击取消按钮后的操作

                        });



                    },
                    copyToClipboard(text) {
                        //将内容放入粘贴板
                        var textarea = document.createElement('textarea');
                        textarea.style.position = 'fixed';
                        textarea.style.opacity = 0;
                        textarea.value = text;
                        document.body.appendChild(textarea);
                        textarea.select();
                        document.execCommand('copy');
                        document.body.removeChild(textarea);
                        VXETable.modal.message({
                            status: 'success',
                            content: '复制成功',
                            duration: 20000
                        })

                    },
                    SessionDelete(node) {
                        console.log(node)
                        let _msg = '';
                        if (node.SessionType === 1) {
                            _msg = '是否删除文件夹 [' + node.Name + '] ?'
                        }
                        if (node.SessionType === 2) {
                            _msg = '是否删除会话 [' + node.Name + '] ?'
                        }


                        //删除节点
                        VxeUI.modal.confirm({
                            title: '提示',
                            content: _msg,
                            okText: '确定',
                            cancelText: '取消',
                            mask: true,
                            lockView: false,
                            escClosable: true
                        }).then((result) => {
                            if (result === 'confirm') {

                                that.TokenID = cache.get('_TokenID');
                                let _param = {
                                    SessionID: node.ID,
                                };

                                $.ajax({
                                    type: "post",
                                    url: Service + "/api/Rdp/SessionDelete",
                                    data: {
                                        TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                        ParamStr: JSON.stringify(_param)
                                    },
                                    async: true, //同步请求
                                    timeout: 10000, //超时时间设置，单位毫秒
                                    dataType: 'json',
                                    crossDomain: true,
                                    success: function (data) {
                                        if (data.Success === 0) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === -999) {
                                            that.ShowLoginPasswordForm = true;
                                        }
                                        if (data.Success === -1) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === 1) {
                                            //let _options = {
                                            //    content: '删除成功!',
                                            //    title: '提示',
                                            //    status: 'warning'
                                            //}
                                            //VXETable.modal.alert(_options)

                                            that.SessionList = data.Result;
                                            that.$nextTick(() => {
                                                that.$refs.treeRef.setAllExpandNode(true);
                                            });
                                            VxeUI.modal.message({ content: '删除成功', status: 'success' })
                                        }

                                    },
                                    error: function (data) {
                                        console.log('服务器执行失败' + data.responseText);
                                    }
                                });
                            }




                        }).catch(() => {
                            // 用户点击取消按钮后的操作

                        });


                    },
                    DirAdd() {
                        //添加文件夹
                        this.SessionInfo.id = '';
                        this.SessionInfo.name = '';
                        this.SessionInfo.server = '';
                        this.SessionInfo.port = '3389';
                        this.SessionInfo.isShareDisk = 'N';
                        this.SessionInfo.description = '';
                        this.ShowDirForm = true;

                    },
                    DirUpdate(node) {
                        //修改文件夹信息
                        this.SessionInfo.id = node.ID;
                        this.SessionInfo.name = node.Name;
                        this.SessionInfo.server = node.Server;
                        this.SessionInfo.port = node.Port;
                        this.SessionInfo.isShareDisk = node.IsShareDisk;
                        this.SessionInfo.description = node.Description;
                        this.ShowDirForm = true;

                    },
                    DirSave() {
                        if (that.SessionInfo.id === '') {
                            //提交新增文件夹
                            that.TokenID = cache.get('_TokenID');

                            let _param = {
                                FSessionID: that.SelectTreeNode == null ? "0" : that.SelectTreeNode.ID,
                                SessionName: that.SessionInfo.name,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/Rdp/DirAdd",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.SessionList = data.Result;
                                        that.$nextTick(() => {
                                            that.$refs.treeRef.setAllExpandNode(true);
                                        });
                                        VxeUI.modal.message({ content: '新增成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });


                        } else {
                            //提交更新文件夹
                            that.TokenID = cache.get('_TokenID');
                            let _param = {
                                SessionID: that.SessionInfo.id,
                                SessionName: that.SessionInfo.name,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/Rdp/DirUpdate",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.SessionList = data.Result;
                                        that.$nextTick(() => {
                                            that.$refs.treeRef.setAllExpandNode(true);
                                        });
                                        VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });

                        }
                    },
                    SessionAdd() {
                        //添加会话
                        this.SessionInfo.id = '';
                        this.SessionInfo.name = '';
                        this.SessionInfo.server = '';
                        this.SessionInfo.port = '3389';
                        this.SessionInfo.userName = '';
                        this.SessionInfo.password = '';
                        this.SessionInfo.isShareDisk = 'N';
                        this.SessionInfo.description = '';
                        this.ShowSessionForm = true;

                    },
                    SessionUpdate(node) {
                        //修改会话信息
                        console.log('SessionUpdate', node);
                        this.SessionInfo.id = node.ID;
                        this.SessionInfo.name = node.Name;
                        this.SessionInfo.server = node.Data.Server;
                        this.SessionInfo.port = node.Data.Port;
                        this.SessionInfo.userName = node.Data.UserName;
                        this.SessionInfo.password = node.Data.Password;
                        this.SessionInfo.isShareDisk = node.Data.IsShareDisk;
                        this.SessionInfo.description = node.Data.Description;
                        this.ShowSessionForm = true;

                    },
                    SessionSave() {
                        if (that.SessionInfo.id === '') {
                            that.TokenID = cache.get('_TokenID');
                            //提交新增文件夹
                            let _param = {
                                FSessionID: that.SelectTreeNode == null ? "0" : that.SelectTreeNode.ID,
                                SessionName: that.SessionInfo.name,
                                Server: that.SessionInfo.server,
                                Port: that.SessionInfo.port,
                                UserName: that.SessionInfo.userName,
                                Password: that.SessionInfo.password,
                                IsShareDisk: that.SessionInfo.isShareDisk,
                                Description: that.SessionInfo.description,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/Rdp/SessionAdd",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.SessionList = data.Result;
                                        that.$nextTick(() => {
                                            that.$refs.treeRef.setAllExpandNode(true);
                                        });
                                        VxeUI.modal.message({ content: '新增成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });


                        } else {
                            //提交更新文件夹
                            that.TokenID = cache.get('_TokenID');
                            let _param = {
                                SessionID: that.SessionInfo.id,
                                SessionName: that.SessionInfo.name,
                                Server: that.SessionInfo.server,
                                Port: that.SessionInfo.port,
                                UserName: that.SessionInfo.userName,
                                Password: that.SessionInfo.password,
                                IsShareDisk: that.SessionInfo.isShareDisk,
                                Description: that.SessionInfo.description,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/Rdp/SessionUpdate",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.SessionList = data.Result;
                                        that.$nextTick(() => {
                                            that.$refs.treeRef.setAllExpandNode(true);
                                        });
                                        VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });

                        }
                    },
                    nodeClick(e) {
                        //点击会话节点
                        this.SelectTreeNode = e.node;
                        console.log('nodeClick', e);

                    },
                    sessionNodeClick() {
                        that.ShowSessionCard = true;
                    },
                    tabChange(e) {
                        if (that.activeTab === 'tab1') {
                            that.PublicKeyLoad();
                        }
                        if (that.activeTab === 'tab2') {
                            that.SessionListLoad();
                        }
                        if (that.activeTab === 'tab3') {
                            that.RoleLoad();
                        }
                        if (that.activeTab === 'tab4') {
                            that.UserLoad();
                        }
                        if (that.activeTab === 'tab5') {

                        }
                    },
                    ChangePassword() {
                        //修改密码
                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                            OldPassword: that.LoginPassword,
                            NewPassword: that.NewLoginPassword,
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/ChangeLoginPassword",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    console.log('ChangeLoginPassword', data);
                                    VxeUI.modal.message({ content: '修改失败', status: 'error' })
                                }
                                if (data.Success === 1) {
                                    VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    RoleLoad() {
                        that.RoleLoading = true;
                        //获取当前公钥信息
                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/RoleList",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                console.log('RoleLoad', data);
                                that.RoleLoading = false;
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.RoleList = data.Result.RoleList;
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    RoleAdd() {
                        //新增角色
                        that.RoleInfo.id = '';
                        that.RoleInfo.name = '';
                        that.ShowRoleForm = true;
                    },
                    RoleUpdate(row) {
                        //修改文件夹信息
                        that.RoleInfo.id = row.ID;
                        that.RoleInfo.name = row.RoleName;
                        that.ShowRoleForm = true;
                    },
                    RoleSave() {
                        if (that.RoleInfo.id === '') {
                            //提交新增文件夹
                            that.TokenID = cache.get('_TokenID');

                            let _param = {
                                RoleName: that.RoleInfo.name,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/RoleAdd",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.RoleList = data.Result.RoleList;
                                        VxeUI.modal.message({ content: '新增成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });


                        } else {
                            //提交更新文件夹
                            that.TokenID = cache.get('_TokenID');
                            let _param = {
                                ID: that.RoleInfo.id,
                                RoleName: that.RoleInfo.name,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/RoleUpdate",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.RoleList = data.Result.RoleList;
                                        VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });

                        }
                    },
                    RoleDelete(row) {
                        let _msg = '';
                        _msg = '是否删除角色 [' + row.RoleName + '] ?'


                        //删除节点
                        VxeUI.modal.confirm({
                            title: '提示',
                            content: _msg,
                            okText: '确定',
                            cancelText: '取消',
                            mask: true,
                            lockView: false,
                            escClosable: true
                        }).then((result) => {
                            if (result === 'confirm') {

                                that.TokenID = cache.get('_TokenID');
                                let _param = {
                                    ID: row.ID,
                                };

                                $.ajax({
                                    type: "post",
                                    url: Service + "/api/User/RoleDelete",
                                    data: {
                                        TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                        ParamStr: JSON.stringify(_param)
                                    },
                                    async: true, //同步请求
                                    timeout: 10000, //超时时间设置，单位毫秒
                                    dataType: 'json',
                                    crossDomain: true,
                                    success: function (data) {
                                        if (data.Success === 0) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === -999) {
                                            that.ShowLoginPasswordForm = true;
                                        }
                                        if (data.Success === -1) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === 1) {
                                            //let _options = {
                                            //    content: '删除成功!',
                                            //    title: '提示',
                                            //    status: 'warning'
                                            //}
                                            //VXETable.modal.alert(_options)

                                            that.RoleList = data.Result.RoleList;
                                            VxeUI.modal.message({ content: '删除成功', status: 'success' })
                                        }

                                    },
                                    error: function (data) {
                                        console.log('服务器执行失败' + data.responseText);
                                    }
                                });
                            }




                        }).catch(() => {
                            // 用户点击取消按钮后的操作

                        });
                    },
                    RoleSession(row) {
                        //角色关联会话
                        that.RoleInfo.id = row.ID;
                        that.RoleInfo.name = row.RoleName;

                        that.TokenID = cache.get('_TokenID');

                        let _param = {
                            ID: that.RoleInfo.id,
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/RoleSessionListGet",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.ShowRoleSessionForm = true;
                                    that.$nextTick(() => {
                                        that.$refs.treeRoleSessionRef.clearCheckboxRow();
                                        that.$refs.treeRoleSessionRef.setCheckboxRowKey(data.Result.SessionIDs, true);
                                        that.$refs.treeRoleSessionRef.setAllTreeExpand(true);
                                    });
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });


                    },
                    RoleSessionAdd() {
                        //保存角色关联会话
                        //勾选的节点
                        let _selectSession = that.$refs.treeRoleSessionRef.getCheckboxRecords(true);
                        //半勾选节点
                        let _selectSession2 = that.$refs.treeRoleSessionRef.getCheckboxIndeterminateRecords(true);
                        let _selectSessionID = [];
                        for (let i = 0; i < _selectSession.length; i++) {
                            _selectSessionID.push(_selectSession[i].ID);
                        }
                        let _param = {
                            RoleID: that.RoleInfo.id,
                            SessionIDs: JSON.stringify(_selectSessionID),
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/RoleSessionListAdd",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    VxeUI.modal.message({ content: '保存成功', status: 'success' })
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    UserLoad() {
                        //获取当前公钥信息
                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/UserList",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                console.log('UserLoad', data);
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.UserList = data.Result.UserList;
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                    UserAdd() {
                        //新增角色
                        that.UserInfo.id = '';
                        that.UserInfo.userid = '';
                        that.UserInfo.name = '';
                        that.UserInfo.isAdmin = 'N';
                        that.UserInfo.password = '';
                        that.ShowUserForm = true;
                    },
                    UserUpdate(row) {
                        //修改文件夹信息
                        that.UserInfo.id = row.ID;
                        that.UserInfo.userid = row.UserID;
                        that.UserInfo.name = row.UserName;
                        that.UserInfo.isAdmin = row.IsAdmin;
                        that.ShowUserForm = true;
                    },
                    UserSave() {
                        if (that.UserInfo.id === '') {
                            //提交新增
                            that.TokenID = cache.get('_TokenID');

                            if (IsEmpty(that.UserInfo.userid)) {
                                let _options = {
                                    content: '登录名不可为空',
                                    title: '提示',
                                    status: 'error'
                                }
                                VXETable.modal.alert(_options)
                                return;
                            }

                            if (IsEmpty(that.UserInfo.name)) {
                                let _options = {
                                    content: '用户名不可为空',
                                    title: '提示',
                                    status: 'error'
                                }
                                VXETable.modal.alert(_options)
                                return;
                            }

                            if (IsEmpty(that.UserInfo.password)) {
                                let _options = {
                                    content: '密码不可为空',
                                    title: '提示',
                                    status: 'error'
                                }
                                VXETable.modal.alert(_options)
                                return;
                            }

                            let _param = {
                                UserID: that.UserInfo.userid,
                                UserName: that.UserInfo.name,
                                IsAdmin: that.UserInfo.isAdmin,
                                Password: CryptoJS.MD5(that.UserInfo.password).toString(),
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/UserAdd",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.UserList = data.Result.UserList;
                                        VxeUI.modal.message({ content: '新增成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });


                        } else {
                            //提交更新
                            if (IsEmpty(that.UserInfo.userid)) {
                                let _options = {
                                    content: '登录名不可为空',
                                    title: '提示',
                                    status: 'error'
                                }
                                VXETable.modal.alert(_options)
                                return;
                            }

                            if (IsEmpty(that.UserInfo.name)) {
                                let _options = {
                                    content: '用户名不可为空',
                                    title: '提示',
                                    status: 'error'
                                }
                                VXETable.modal.alert(_options)
                                return;
                            }

                            that.TokenID = cache.get('_TokenID');
                            let _param = {
                                ID: that.UserInfo.id,
                                UserID: that.UserInfo.userid,
                                UserName: that.UserInfo.name,
                                IsAdmin: that.UserInfo.isAdmin,
                            };

                            $.ajax({
                                type: "post",
                                url: Service + "/api/User/UserUpdate",
                                data: {
                                    TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                    ParamStr: JSON.stringify(_param)
                                },
                                async: true, //同步请求
                                timeout: 10000, //超时时间设置，单位毫秒
                                dataType: 'json',
                                crossDomain: true,
                                success: function (data) {
                                    if (data.Success === 0) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === -999) {
                                        that.ShowLoginPasswordForm = true;
                                    }
                                    if (data.Success === -1) {
                                        let _options = {
                                            content: data.ErrorMessage,
                                            title: '提示',
                                            status: 'error'
                                        }
                                        VXETable.modal.alert(_options)
                                    }
                                    if (data.Success === 1) {
                                        //let _options = {
                                        //    content: '新增文件夹成功!',
                                        //    title: '提示',
                                        //    status: 'warning'
                                        //}
                                        //VXETable.modal.alert(_options)
                                        that.UserList = data.Result.UserList;
                                        VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                    }

                                },
                                error: function (data) {
                                    console.log('服务器执行失败' + data.responseText);
                                }
                            });

                        }
                    },
                    UserDelete(row) {
                        let _msg = '';
                        _msg = '是否删除操作员 [' + row.UserName + '] ?'


                        //删除节点
                        VxeUI.modal.confirm({
                            title: '提示',
                            content: _msg,
                            okText: '确定',
                            cancelText: '取消',
                            mask: true,
                            lockView: false,
                            escClosable: true
                        }).then((result) => {
                            if (result === 'confirm') {

                                that.TokenID = cache.get('_TokenID');
                                let _param = {
                                    ID: row.ID,
                                };

                                $.ajax({
                                    type: "post",
                                    url: Service + "/api/User/UserDelete",
                                    data: {
                                        TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                        ParamStr: JSON.stringify(_param)
                                    },
                                    async: true, //同步请求
                                    timeout: 10000, //超时时间设置，单位毫秒
                                    dataType: 'json',
                                    crossDomain: true,
                                    success: function (data) {
                                        if (data.Success === 0) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === -999) {
                                            that.ShowLoginPasswordForm = true;
                                        }
                                        if (data.Success === -1) {
                                            let _options = {
                                                content: data.ErrorMessage,
                                                title: '提示',
                                                status: 'error'
                                            }
                                            VXETable.modal.alert(_options)
                                        }
                                        if (data.Success === 1) {
                                            //let _options = {
                                            //    content: '删除成功!',
                                            //    title: '提示',
                                            //    status: 'warning'
                                            //}
                                            //VXETable.modal.alert(_options)

                                            that.UserList = data.Result.UserList;
                                            VxeUI.modal.message({ content: '删除成功', status: 'success' })
                                        }

                                    },
                                    error: function (data) {
                                        console.log('服务器执行失败' + data.responseText);
                                    }
                                });
                            }




                        }).catch(() => {
                            // 用户点击取消按钮后的操作

                        });
                    },
                    UserChangePassword(row) {
                        //修改用户密码
                        that.UserInfo.id = row.ID;
                        that.UserInfo.password = '';
                        that.ShowUserChangePasswordForm = true;
                    },
                    UserPasswordSave() {
                        //修改用户密码保存
                        if (IsEmpty(that.UserInfo.password)) {
                            let _options = {
                                content: '密码不可为空',
                                title: '提示',
                                status: 'error'
                            }
                            VXETable.modal.alert(_options)
                            return;
                        }

                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                            ID: that.UserInfo.id,
                            Password: CryptoJS.MD5(that.UserInfo.password).toString(),
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/UserChangePassword",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    VxeUI.modal.message({ content: '修改成功', status: 'success' })
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    UserRole(row) {
                        //角色关联会话
                        that.UserInfo.id = row.ID;
                        that.UserInfo.name = row.UserName;

                        that.TokenID = cache.get('_TokenID');

                        let _param = {
                            ID: that.UserInfo.id,
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/UserRoleListGet",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.ShowUserRoleForm = true;
                                    that.$nextTick(() => {
                                        console.log(data.Result.RoleIDs)
                                        that.$refs.treeUserRoleRef.clearCheckboxRow();
                                        that.$refs.treeUserRoleRef.setCheckboxRowKey(data.Result.RoleIDs, true);
                                        that.$refs.treeUserRoleRef.setAllTreeExpand(true);
                                    });
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });


                    },
                    UserRoleAdd() {
                        //保存角色关联会话

                        let _selectRole = that.$refs.treeUserRoleRef.getCheckboxRecords(true);
                        let _selectRoleID = [];
                        for (let i = 0; i < _selectRole.length; i++) {
                            _selectRoleID.push(_selectRole[i].ID);
                        }
                        let _param = {
                            UserID: that.UserInfo.id,
                            RoleIDs: JSON.stringify(_selectRoleID),
                        };

                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/UserRoleListAdd",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: true, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -999) {
                                    that.ShowLoginPasswordForm = true;
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    VxeUI.modal.message({ content: '保存成功', status: 'success' })
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });
                    },
                    UserLogLoad() {
                        //获取当前公钥信息
                        that.TokenID = cache.get('_TokenID');
                        let _param = {
                            BeginTime: that.UserLogBeginTime,
                            EndTime: that.UserLogEndTime,
                        };


                        $.ajax({
                            type: "post",
                            url: Service + "/api/User/UserLogList",
                            data: {
                                TokenID: IsEmpty(that.TokenID) ? '' : that.TokenID,
                                ParamStr: JSON.stringify(_param)
                            },
                            async: false, //同步请求
                            timeout: 10000, //超时时间设置，单位毫秒
                            dataType: 'json',
                            crossDomain: true,
                            success: function (data) {
                                console.log('UserLogLoad', data);
                                if (data.Success === 0) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === -1) {
                                    let _options = {
                                        content: data.ErrorMessage,
                                        title: '提示',
                                        status: 'error'
                                    }
                                    VXETable.modal.alert(_options)
                                }
                                if (data.Success === 1) {
                                    that.UserLogList = data.Result.UserLogList;
                                }

                            },
                            error: function (data) {
                                console.log('服务器执行失败' + data.responseText);
                            }
                        });

                    },
                }
            })




        });

    </script>
</body>
</html>

